package com.tungse.study.rpc.service.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tungse.study.rpc.domain.ProducerUser;
import com.tungse.study.rpc.service.ProducerService;

/**
 * @author Tungse
 */
public class ProducerServiceImpl implements ProducerService {

    @Override
    public ProducerUser getUser(String name) {
        return ProducerUser.builder().name(name).age(18).build();
    }

    @Override
    public void saveUser(ProducerUser user) {
        try {
            System.out.println("保存成功：" + new ObjectMapper().writeValueAsString(user));
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }


}
